//
//  RootViewController.m
//  GJNK
//
//  Created by xmdfst on 16/10/13.
//  Copyright © 2016年 LYX. All rights reserved.
//

#import "RootViewController.h"
#import "MainTabBarViewController.h"
#import "YXNavigationController.h"



@interface RootViewController ()


@end

@implementation RootViewController
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self onLoginSucess];
    
}

/**
 *  @author LYX, 16-10-14 10:10:40
 *
 *  登陆成功 切换到主页
 */
-(void)onLoginSucess
{
    for (UIViewController *childVC in self.childViewControllers) {
        [childVC removeFromParentViewController];
        [childVC.view removeAllSubviews];
    }
    
    MainTabBarViewController *tabVC = [[MainTabBarViewController alloc] init];
    [self addChildViewController:tabVC];
    [self.view addSubview:tabVC.view];
}

+(RootViewController*)instance
{
    static dispatch_once_t pred = 0;
    __strong static id _sharedObject = nil;
    dispatch_once(&pred, ^{
        _sharedObject = [[self alloc] init]; // or some other init method
        
    });
    return _sharedObject;
}

@end
